home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / winvn060.arc / VEC_SRCH.C < prev    next >
C/C++ Source or Header  |  1991-07-01  |  3KB  |  117 lines

  1. /* MRR's modified version to try to get it to work with
  2.  *  Windows 3.0.
  3.  * This is the second time--Oh, how I hate PWB!!!
  4.  *
  5.  *  Mark Riordan     23-SEP-1990
  6.  */
  7. /*
  8.  * SRCLIB\NETLIB\VEC_SRCH.C
  9.  *
  10.  * Copyright (C) 1986,1987,1988 by FTP Software, Inc.
  11.  * 
  12.  * This software is furnished under a license and may be used and copied
  13.  * only in accordance with the terms of such license and with the
  14.  * inclusion of the above copyright notice. This software or any other
  15.  * copies thereof may not be provided or otherwise made available to any
  16.  * other person. No title to and ownership of the software is hereby
  17.  * transferred.
  18.  * 
  19.  * The information in this software is subject to change without notice
  20.  * and should not be construed as a commitment by FTP Software, Inc.
  21.  * 
  22.  * EDIT HISTORY:
  23.  * 05-Feb-88    jog    basically lifted from 'old' versions of _find_vec
  24.  *              routine
  25.  *         jbvb    Clean up leftover code.
  26.  * 23-Feb-88    jbvb    Use new pctcp_cleanup() for onexit() shutdown.
  27.  * 24-Feb-88    jbvb    Add logic to turn off DOS BREAK ON, and save old
  28.  *             state in _dos_break so pctcp_cleanup() can restore
  29.  *             it when we exit.
  30.  * 27-Feb-88    jbvb    Don't modify syscall interrupt directly - call the
  31.  *             library to do it.
  32.  * 02-Mar-88    jbvb    Use correct argument to DOS call
  33.  */
  34.  
  35. #include <dos.h>
  36.  
  37. #define    FIRST_VEC    0x20
  38. #define    LAST_VEC    0xE0
  39.  
  40. /* find the packet driver vector - returns the vector number, or 0 on
  41.     failure.
  42. */
  43.  
  44. int    _pctcp_int = 0;        /* global which is our syscall interrupt */
  45. int    _dos_break = 0;        /* DL returned from DOS function 33h */
  46.  
  47. static char match[] = "TCPTSR";
  48.  
  49. extern void _net_set_vector();
  50. extern void pctcp_cleanup();
  51. static int check_match(char far *t);
  52.  
  53. int
  54. vec_search()
  55. {
  56.     int i = 0x61;
  57.  
  58.     _pctcp_int = i;        /* set the global variable */
  59. #if 0
  60.     _net_set_vector(i);     /* Modify library call */
  61. #endif
  62.     return(i);
  63. }
  64.  
  65. old_vec_search()
  66. {
  67.     char far * (far *vec);        /* pointer into the interrupt table */
  68.     register int i;
  69.     char far *handler;    /* pointer to an interrupt handler */
  70.     union REGS reg;
  71.  
  72.     FP_SEG(vec) = 0;
  73.  
  74.     for(i = FIRST_VEC; i < LAST_VEC; i++) {
  75.         /* fixup the pointer into the table
  76.         */
  77.         FP_OFF(vec) = i << 2;
  78.  
  79.         /* get the handler and bump it (hopefully) over the jmp
  80.         */
  81.         handler = *vec + 3;
  82.         
  83.         /* check if it points at PC/TCP kernel's service routine.
  84.         */
  85.         if(check_match(handler)) {
  86.             _pctcp_int = i;        /* set the global variable */
  87.  
  88.             _net_set_vector(i);    /* Modify library call */
  89.  
  90.             reg.x.ax = 0x3300;    /* Get BREAK state */
  91.             intdos(®, ®);
  92.             _dos_break = reg.h.dl;    /* Save old BREAK state */
  93.  
  94.             reg.x.ax = 0x3301;    /* Set BREAK state */
  95.             reg.h.dl = 0;        /*  to OFF for PC/TCP */
  96.             intdos(®, ®);
  97.             
  98.             onexit(pctcp_cleanup);    /* Hook shutdown function */
  99.             return i;
  100.             }
  101.         }
  102.  
  103.         return (0);
  104.     }
  105.  
  106. static int
  107. check_match(t)
  108.     char far *t; {
  109.     register char *s;
  110.     
  111.     for(s = match; *s; s++)
  112.         if(*t++ != *s)
  113.             return 0;
  114.  
  115.     return 1;
  116.     }
  117.